package com.econ.powercloud.ems.common.enums;

import com.google.common.collect.Lists;

import java.util.List;
import java.util.Objects;

/**
 * @author jwc
 * @date 2022/11/11
 */
public enum CategoryEnum implements EnumMethod {
    BATTERY_MONITOR(1,"电池监控"),
    OVERVIEW(2, "总览"),
    AGC(3, "AGC"),
    AVC(4, "AVC"),
    PRIMARY_FREQUENCY_CONTROL(5, "一次调频"),
    REACTIVE_POWER(6, "动态无功调压"),
    PRECISE_CUT(7, "精准切负荷"),
    CHARGE_PLAN(8, "充放电计划"),
    SMOOTH(9,"平滑出力"),
    ECON_MODEL(10,"经济模式"),
    DEVICE_MONITOR(11,"储能站设备监控"),
    ;


    private Integer code;
    private String desc;

    CategoryEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    public static String getDescFromCode(int code){
        for(CategoryEnum e: CategoryEnum.values()){
            if(e.getCode() == code){
                return e.getDesc();
            }
        }
        return "";
    }

    public static CategoryEnum fromName(String name){
        for(CategoryEnum e: CategoryEnum.values()){
            if(Objects.equals(e.name(),name)){
                return e;
            }
        }
        return null;
    }

    public static List<CategoryEnum> fromNames(List<String> nameList){
        List<CategoryEnum> result = Lists.newArrayList();
        for(CategoryEnum e: CategoryEnum.values()){
            if(nameList.contains(e.name())){
                result.add(e);
            }
        }
        return result;
    }

}
